home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8409.arc
/
STRINSER.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-09-14
|
1KB
|
48 lines
; ROUTINE TO INSERT ONE STRING WITHIN ANOTHER
;
;addressing equates
essorc equ es:[si] ; equate for source in extra seg
dsdest equ byte ptr[di] ; equate for usual destination
strinsert proc far
;
push si ; save registers
push di
push cx
push ax
;
; find current end of destination string
mov si,bp ; start of string
add si,es:[si] ; point to next to last byte
inc si ; adjust for length information
;
; find new end of destination string and update length
mov di,si ; get old end of destination
mov ax,[bx] ; get length of source
add di,ax ; new end of destination
add es:[bp],ax ; new length of destination
;
; move tail of destination string out of the way
mov cx,si ; SI - DX + 1 is the count
sub cx,dx
inc cx
std ; backward direction
rep movs dsdest,essorc ; move the tail
;
; move source string into place
mov di,dx ; destination of move
mov si,bx ; source of move
cld ; forward direction
lodsw ; length of source
mov cx,ax ; the count
rep movsb ; make the string move
;
strinsertexit:
pop ax ; restore registers
pop cx
pop di
pop si
ret
;
strinsert endp